package cn.sfinger.huifu.p2p.util.security;

public class Int32Manipulator
{
  public static void HPERM_OP(int[] paramArrayOfInt, int paramInt1, int paramInt2, int paramInt3)
  {
    int i = paramArrayOfInt[0];
    paramInt1 = (i << 16 - paramInt2 ^ i) & paramInt3;
    i = i ^ paramInt1 ^ paramInt1 >>> 16 - paramInt2;
    paramArrayOfInt[0] = i;
  }

  public static void PERM_OP(int[] paramArrayOfInt1, int[] paramArrayOfInt2, int paramInt1, int paramInt2, int paramInt3)
  {
    int i = paramArrayOfInt1[0];
    int j = paramArrayOfInt2[0];
    paramInt1 = (i >>> paramInt2 ^ j) & paramInt3;
    j ^= paramInt1;
    i ^= paramInt1 << paramInt2;
    paramArrayOfInt1[0] = i;
    paramArrayOfInt2[0] = j;
  }

  public static int bytes_to_int(byte[] paramArrayOfByte, int paramInt)
  {
    return paramArrayOfByte[paramInt] & 0xFF | (paramArrayOfByte[(paramInt + 1)] & 0xFF) << 8 | (paramArrayOfByte[(paramInt + 2)] & 0xFF) << 16 | (paramArrayOfByte[(paramInt + 3)] & 0xFF) << 24;
  }

  public static int c2ln(byte[] paramArrayOfByte, int paramInt1, int paramInt2, int[] paramArrayOfInt)
  {
    int i = paramInt2;
    paramArrayOfInt[0] = 0;
    paramArrayOfInt[1] = 0;
    switch (paramInt2)
    {
    case 8:
      paramArrayOfInt[1] = ((paramArrayOfByte[(paramInt1 + --paramInt2)] & 0xFF) << 24);
    case 7:
      paramArrayOfInt[1] |= (paramArrayOfByte[(paramInt1 + --paramInt2)] & 0xFF) << 16;
    case 6:
      paramArrayOfInt[1] |= (paramArrayOfByte[(paramInt1 + --paramInt2)] & 0xFF) << 8;
    case 5:
      paramArrayOfInt[1] |= paramArrayOfByte[(paramInt1 + --paramInt2)] & 0xFF;
    case 4:
      paramArrayOfInt[0] = ((paramArrayOfByte[(paramInt1 + --paramInt2)] & 0xFF) << 24);
    case 3:
      paramArrayOfInt[0] |= (paramArrayOfByte[(paramInt1 + --paramInt2)] & 0xFF) << 16;
    case 2:
      paramArrayOfInt[0] |= (paramArrayOfByte[(paramInt1 + --paramInt2)] & 0xFF) << 8;
    case 1:
      paramArrayOfInt[0] |= paramArrayOfByte[(paramInt1 + --paramInt2)] & 0xFF;
    }

    return i;
  }

  public static int l2cn(byte[] paramArrayOfByte, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    int i = paramInt2;
    switch (paramInt2)
    {
    case 8:
      paramArrayOfByte[(paramInt1 + --paramInt2)] = ((byte)(paramInt4 >>> 24 & 0xFF));
    case 7:
      paramArrayOfByte[(paramInt1 + --paramInt2)] = ((byte)(paramInt4 >>> 16 & 0xFF));
    case 6:
      paramArrayOfByte[(paramInt1 + --paramInt2)] = ((byte)(paramInt4 >>> 8 & 0xFF));
    case 5:
      paramArrayOfByte[(paramInt1 + --paramInt2)] = ((byte)(paramInt4 & 0xFF));
    case 4:
      paramArrayOfByte[(paramInt1 + --paramInt2)] = ((byte)(paramInt3 >>> 24 & 0xFF));
    case 3:
      paramArrayOfByte[(paramInt1 + --paramInt2)] = ((byte)(paramInt3 >>> 16 & 0xFF));
    case 2:
      paramArrayOfByte[(paramInt1 + --paramInt2)] = ((byte)(paramInt3 >>> 8 & 0xFF));
    case 1:
      paramArrayOfByte[(paramInt1 + --paramInt2)] = ((byte)(paramInt3 & 0xFF));
    }

    return i;
  }

  public static void set_int(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
  {
    paramArrayOfByte[(paramInt1++)] = ((byte)(paramInt2 & 0xFF));
    paramArrayOfByte[(paramInt1++)] = ((byte)(paramInt2 >>> 8 & 0xFF));
    paramArrayOfByte[(paramInt1++)] = ((byte)(paramInt2 >>> 16 & 0xFF));
    paramArrayOfByte[(paramInt1++)] = ((byte)(paramInt2 >>> 24 & 0xFF));
  }
}
